@extends('admin.layout.layout', ['row' => @$page])

@section('contain')


    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
            </div>
            <div class="actions"></div>
        </div>

        <div class="filter-wrapper">
            <form action="/{{ request()->path() }}/" class="form-inline filter-form">
                <div class=" input-group mb-3 custom-control-inline">
                    <input type="text" class="form-control s-input" name="value" value="{{ request()->input('value') }}" placeholder="{{ ts('WARRANTYSEARCHTEXT') }}">
                </div>
                <div class="input-group mb-3 custom-control-inline">
                    <select name="status" class="form-control">
                        <option value="">{{ ts('select').' '.ts('status') }}</option>
                        <option value="0" {{ request()->input('status') !== null && request()->input('status') == 0 ? 'selected' : '' }}>{{ ts('STA0') }}</option>
                        <option value="1" {{ request()->input('status') == 1 ? 'selected' : '' }}>{{ ts('STA1') }}</option>
                        <option value="2" {{ request()->input('status') == 2 ? 'selected' : '' }}>{{ ts('STA2') }}</option>
                    </select>
                </div>
                <x-flatpickr-date-range label="{{ ts('fqrq') }}"></x-flatpickr-date-range>
                <div class="mb-3">
                    <button class="btn btn-primary">{{ ts('SEARCH') }}</button>
                    <a href="/{{ request()->path() }}/" class="btn btn-warning">{{ ts('RESET') }}</a>
                </div>

            </form>
        </div>

        <div>
            <table class="table text-nowrap bt-table d-none">
                <thead>
                <tr class="order_column">
                    {{--<th></th>--}}
                    <th>{{ ts('sequence') }}</th>
                    <th>{{ ts('SQR') }}</th>
                    <th>{{ ts('ROLLnumber') }}</th>
                    <th>{{ ts('licenseplate') }}</th>
                    <th>{{ ts('length') }}</th>
                    <th>{{ ts('fqrq') }}</th>
                    <th>{{ ts('INSTALLERNAME') }}</th>
                    <th>{{ ts('qudao') }}</th>
                    <th>{{ ts('status') }}</th>
                    <th>{{ ts('OPERATIONS') }}</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $k => $v)
                    <tr class="item-list">
                        {{--<td class="text-center">
                            <input type="checkbox" class="warranty_icheck icheck_input" name="ids[]" value="{{ $v->id }}">
                        </td>--}}
                        <td class="text-center">{{ @$data->firstItem()+$k }}</td>
                        <td>{{ @$v->sqr }}</td>
                        <td>
                            @empty($coverages[$v->warranty_id])
                            @else
                                @foreach($coverages[$v->warranty_id] as $r)
                                    <div>{{ @$r->roll_number }}</div>
                                @endforeach
                            @endif
                        </td>
                        <td>{{ @$v->license_plate }}</td>
                        <td>
                            @empty($coverages[$v->warranty_id])
                                0
                            @else
                                {{ array_sum(\Illuminate\Support\Arr::pluck($coverages[$v->warranty_id], 'length')) }} cm
                            @endif
                        </td>
                        <td>
                            {{ fdate2(@$v->created_at) }}
                        </td>
                        <td>{{ @$v->installer_name }}</td>
                        <td>{{ @$v->jxsmc }}</td>
                        <td>{{ ts('sta'.$v->approved) }}</td>
                        <td>
                            <a class="btn btn-success btn-sm" href='/{{ request()->path() }}/{{ $v->id }}'>{{ ts('VIEW') }}</a>
                            {{--<span class="btn btn-danger btn-sm" onclick="handleDelete({{ $v->id }})">{{ ts('delete') }}</span>--}}
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>

            <div class="row my-3">
                {{ $data->appends(request()->input())->links() }}
            </div>
        </div>

    </div>


@endsection

@section('script')
    <script>
        $(document).ready(function () {
            $('.table.bt-table').bootstrapTable({
                fixedColumns: true,
                fixedRightNumber: 1,
            }).removeClass('d-none')
        })
    </script>
@endsection